<?php
    header("Content-Type: text/html;charset=utf-8");

    $mysqli = new mysqli("localhost","root","root","ibalian");
    if($mysqli->connect_errno != 0){
        die();
    };

    $page = $_GET['page'];
    $star = ($page - 1) * 6;

    $sql = "select * from person_list limit {$star} , 6";
    $res = $mysqli->query($sql);
    if ($res->num_rows > 0){
        //查询到数据
        for($i = 0; $i < $res->num_rows;$i++){
            $data[] = $res->fetch_assoc();
        }
        $data["data"] = $data;
        $data["code"] = 1;
    }else{
        //没有数据
        $data["code"] = 0;
    }
    // $res = $mysqli->query($sql);
    // for($i = 0; $i < $res->num_rows;$i++){
    //     $tabData[] = $res->fetch_assoc();
    // }
    print_r(json_encode($data));
?>